import {
  app_share_params
} from '@/api/home'
Page({

  data: {
    imgUri: getApp().globalData.imgUri,
    cdn: getApp().globalData.cdn,
    currentIndex:0,
    userId:0,
    share_title:'',
    share_image:'',
  },
  onLoad(){
    let t = this;
    var getgemomemberuser = wx.getStorageSync('getgemomemberuser');
    this.setData({
      userId:getgemomemberuser.userId
    });

    app_share_params({}).then(res => {
      if(res.code == 200){
        var data = JSON.parse(res.data)
        t.setData({
          share_title:data.context,
          share_image:t.data.cdn+data.image,
        });

      }
    });
  },

  changeSwiper(e){
    console.log(e.detail.current)
    let index = e.detail.current
    if(index == 0 || index == 2){
      this.setData({
        currentIndex:0
      })
    }else{
      this.setData({
        currentIndex:1
      })
    }
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
    return {
      title: this.data.share_title,
      path: "/pages/register/register?inviterId="+this.data.userId,
      imageUrl: this.data.share_image,
    }
  }
})